<?php

/**
 * lote form.
 *
 * @package    plagas
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class loteForm extends BaseloteForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'id'                 => new sfWidgetFormInputHidden(),
      'nro'                => new sfWidgetFormInputText(),
      'hectareas'          => new sfWidgetFormInputText(),
      'establecimiento_id' => new sfWidgetFormDoctrineChoice(array(
          'model'     => 'establecimiento',
          'add_empty' => false,
          'table_method'=> 'getEstablecimientos')),
    ));

    $this->setValidators(array(
      'id'                 => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'nro'                => new sfValidatorInteger(),
      'hectareas'          => new sfValidatorInteger(array('required' => false)),
      'establecimiento_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('establecimiento'))),
    ));

    $this->widgetSchema->setNameFormat('lote[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();
  }
}
